package com.gadgets.busi.bm02.dto;

import com.gadgets.framework.common.dto.BaseDTO;

import java.util.ArrayList;
import java.util.List;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020-11-02
 * 
 */
public class RecipeResultDTO extends BaseDTO {

    /**
     * 物资名
     */
    private String name;
    /**
     * 需求数量
     */
    private Double num;
    /**
     * 是否叶子结点
     * 默认叶子节点
     */
    private String isLeaf;
    /**
     * 合成表
     */
    private List<RecipeResultDTO> sonList = new ArrayList<>();

    public String getIsLeaf() {
        return sonList.size()>0?"0":"1";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getNum() {
        return num;
    }

    public void setNum(Double num) {
        this.num = num;
    }

    public List<RecipeResultDTO> getSonList() {
        return sonList;
    }

    public void setSonList(List<RecipeResultDTO> sonList) {
        this.sonList = sonList;
    }

    public void addSonRecipe(RecipeResultDTO recipeResultDTO){
        sonList.add(recipeResultDTO);
    }

    @Override
    public int hashCode() {
        return this.name.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof RecipeResultDTO){
            return this.name.hashCode() == obj.hashCode();
        }
        return false;
    }
}
